
<template>
  <div>
    <van-cell-group class="myInfo" v-if="user">
      <van-cell title="单元格" class="van-celltt" value="内容" center :border="false">
        <van-image class="vanImage" slot="icon" width="66" round height="66" :src="userData.photo" />
        <div slot="title" class="nicheng">{{userData.name}}</div>
        <van-button round size="small" class="btnSmall" to="/user/profile">编辑资料</van-button>
      </van-cell>
      <van-grid class="firstGird" :border="false">
        <van-grid-item class="firstGirdItem" text="文字">
          <div slot="text">
            <div class="span">{{userData.art_count}}</div>
            <div class="text">头条</div>
          </div>
        </van-grid-item>
        <van-grid-item text="文字">
          <div slot="text">
            <div class="span">{{userData.follow_count}}</div>
            <div class="text">关注</div>
          </div>
        </van-grid-item>
        <van-grid-item text="文字">
          <div slot="text">
            <div class="span">{{userData.fans_count}}</div>
            <div class="text">粉丝</div>
          </div>
        </van-grid-item>
        <van-grid-item text="文字">
          <div slot="text">
            <div class="span">{{userData.like_count}}</div>
            <div class="text">获赞</div>
          </div>
        </van-grid-item>
      </van-grid>
    </van-cell-group>
    <div class="showWei" v-else>
      <img src="../../utils/头像.png" class="touxiang" @click="$router.push('/login')" />
      <div class="text">
        <span>登录</span>/
        <span>注册</span>
      </div>
    </div>
    <van-grid :column-num="2" class="vanGrids mb-4" icon-size="22px" center>
      <!-- <van-icon name="" /> -->
      <van-grid-item icon="star-o" text="收藏" class="vanGridsItem" />
      <van-grid-item
        icon-prefix="iconfont"
        icon="iconfont iconlishi"
        class="vanGridsItem"
        text="历史"
      />
    </van-grid>

    <van-cell class="itemCell" title="消息通知" is-link to />
    <van-cell title="小爱同学" class="itemCell mb-4" is-link to />
    <van-cell title="退出登录" @click="tuichuLogin" class="tuichu" v-if="user" />
    
  </div>
</template>
<script>
import { mapState } from "vuex";
import { getUserData } from "@/api/user";
export default {
  computed: {
    ...mapState(["user"]),
  },
  data() {
    return {
      userData: "",
      isLoading: false
      
    };
  },
  methods: {
      
    tuichuLogin() {
      this.$dialog
        .confirm({
          title: "退出提示",
          message: "您确定要退出吗",
        })
        .then(() => {
          //这个是确定要退出
          //  我们就要退出登录的状态
          this.$store.commit("setUser", null);
        })
        .catch(() => {});
    },
    loadCurrentUser() {
      return getUserData();
    },
    onRefresh() {
      // console.log(55555);
    },
  },
  async created() {
    var { data } = await this.loadCurrentUser();

    this.userData = data.data;
    // console.log(this.userData);
  },
};
</script>
<style scoped lang="less">
.nicheng {
  width: auto;
  text-align: left;
}

.firstGird .firstGirdItem {
  height: 65px;
}
.span {
  color: #ffffff;
  font-size: 16px;
}
.text {
  color: #ffffff;
  font-size: 11px;
}
.itemCell {
  text-align: left;
}

.myInfo {
  background: url(../../utils/banner.png);
  background-size: cover;
  .van-celltt {
    background-color: unset;
    box-sizing: border-box;
    height: 115px;
    padding-top: 37px;
    padding-bottom: 11px;
    .nicheng {
      font-size: 15px;
      margin-left: 10px;
      color: #ffffff;
    }
    .vanImage {
      border: 1px solid #ffffff;
      box-sizing: border-box;
      .van-cell__title {
        margin-top: 61px;
      }
    }
    .btnSmall {
      // width: 58px;
      height: 16px;
      color: #666666;
      font-size: 10px;
    }
  }
}
/deep/.van-grid-item__content {
  background-color: unset;
}
/deep/.vanGrids {
  background: #ffffff;
  // height: 70px;
  .vanGridsItem {
    height: 70px;
    .van-grid-item__icon {
      color: #eb5253;
    }
    .iconlishi {
      color: #ff9d1d;
    }
    .van-grid-item__text {
      font-size: 14px;
      color: #333333;
    }
  }
}
.mb-4 {
  margin-bottom: 4px;
}
.tuichu {
  color: #eb5253;
}
.showWei {
  box-sizing: border-box;
  padding-top: 54px;
  height: 180px;
  background: url(../../utils/banner.png);
  background-size: cover;

  .touxiang {
    height: 66px;
    width: 66px;
  }
  .text {
    font-size: 14px;
    span {
      margin-right: 4px;
    }
    span:last-child {
      margin-left: 4px;
    }
  }
}
</style>
// http://ttapi.research.itcast.cn/app/v1_0/user?Authorization=Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MDA3MDk2OTQsInVzZXJfaWQiOjEsInJlZnJlc2giOmZhbHNlfQ.6QL8_SyDRoeQ24-kynpPKQnRuGPf01PyWHn7XFepNsg